package com.ygly.struts.pro;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ygly.struts.actions.SqlAction;
import com.ygly.struts.models.Pro;

public class EditPro extends ActionSupport {

	/**
	 * @return
	 */
	Pro pro;
	public Pro getPro() {
		return pro;
	}

	public void setPro(Pro pro){
		this.pro = pro;
	}
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		ActionContext con = ActionContext.getContext();
		HttpServletRequest request = (HttpServletRequest )con.get(ServletActionContext.HTTP_REQUEST);
		int proid = pro.getId();
		String intr = pro.getIntr();
		int open;
		if(pro.getOpen() == null)	open = 0;
		else open = 1;
		String update = "update pro set Introduction='"+intr+"', Open='"+open+"' where Id='"+proid+"'";
		SqlAction sql = new SqlAction();
		sql.OpenConn();
		sql.executeUpdata(update);
		request.setAttribute("iddd", proid);
		return "SUCCESS";
	}
}